<template>
    <div>
        <input type="text" v-model="v">
        <button @click="save(v)">commit now</button>
        <button @click="savelater(v)">commit later</button>
        <h2>{{'time is :'+$store.state.time}}</h2>
    </div>
</template>

<script>
export default ({
    name:'com_a',
    data:function(){
        return {
            v:''
        }
    },
    methods:{
        save:function(v){
            console.log(v)
            this.$store.commit('getvalue',v)
        },
        savelater:function(payload){
            this.$store.dispatch('a_getvalue',payload)
            setInterval(() => {
                this.$store.commit('countdown')
            }, 1);
        },
        // timing:function(){
            
        // }
    }
})
</script>
